package features.advance.ch1;

import java.io.File;
import java.io.FileInputStream;

public class demo_impl_001 implements demo_001{

    @Override
    public void test(String filename) {
        File file = new File(filename);
        try (FileInputStream fis = new FileInputStream(file)) {
            System.out.println("start");
            int code = -1;
            int i = 1;
            while((code = fis.read()) != -1) {
                System.out.println(i+++":");
                System.out.println("int类型的值为"+code);
                System.out.println("char类型的值为"+(char)code);
            }
            System.out.println("end");
            if(fis!=null){
                fis.close();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
